<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{{.info.title}}</title>
    <meta charset="utf-8" name="keywords" content="统采商城,采购" />
    <meta charset="utf-8" name="description" content="统采商城" />
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/index.min.css" />
    <!-- <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/top.min.css?v=123" /> -->
    <link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/font/iconfont.css">
    <link rel="stylesheet" type="text/css" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/css/pc/pcbase.css?v=1">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/xcConfirm.css">
    <link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/css/toast.css" />
    <style type="text/css">
    .logo{width: 60px !important}
    .prd>div .prd_l .prdInfo .prdImgs ul li {
        float: left;
    }
    .prd>div .prd_l .prdInfo .prdImgs ul li.ac:after {
      box-shadow: inset 2px 2px 0 #e4393c, inset -2px -2px 0 #e4393c;
  }
  .pDParameter>p{
    width: 33%;float: left;
    margin-bottom: 0px !important;
    padding: 3px;
  }
  .pDParameter{
    overflow: hidden;
  }
  .pDInfo img{
    width: 100% !important;
    height: auto !important;
  }
  .prd>div .prd_l .prdDetail .prdStore .pSInfo .pSInfoCont dl{width: 50% !important}
  .pDEva>div dl dd:nth-of-type(1){margin-top: 28px;}
  .prdCont dl dt,.prdCont dl dd{cursor: default !important; }
  .pricem dd{line-height: 40px;font-size: 20px;font-weight: 900}
  .pricem dt{line-height: 40px;}
  .pricem{border-top: 1px dashed #e4393c;border-bottom: 1px dashed #e4393c }
  .pCSale p{width: 30% !important;margin: 0!important}
  .pCSale p:nth-of-type(even){text-align: right;}
  .gg dd>span{border: 1px solid #eee;padding:3px 7px;border-radius: 3px;margin-left: 0 !important}
  .gg{margin-bottom: 10px;}
  .gg .on{border-color: #e4393c;color: #e4393c !important}
   .service img{width: 20px;height: 20px;vertical-align: center}
   .service{height: 36px;padding-left: 10px;line-height: 36px;}
  </style>
  </head>
  <body style="overflow-x: auto!important;" class="search">
    <!--from fragment-->
     {{template "pc/public/head.html" .}}
    <div class="storeHeader">
      <div>
        {{if .shop}}
        <div class="logo"><img src="{{.shop.pathname}}"></div>
        <div class="storeInfo">
          <dl>
            <a href="/shop?id={{.shop.id}}"><dt>{{.shop.name}}</dt></a>
            <!-- <dd><label>品牌直销</label></dd> -->
          </dl>
        {{else}}
        <div class="logo"><img src="{{$.system.pathname}}"></div>
        <div class="storeInfo">
          <dl>
            <a href="/shop?id=0"><dt>{{$.system.name}}</dt></a>
            <dd><label>官方自营</label></dd>
          </dl>
        {{end}}
          <div class="score">
            <dl>
              <dt>服务</dt>
              <dd>{{.score.avgscore}}<!-- <i class="iconfont">&#xe818;</i> --></dd>
            </dl>
            <dl>
              <dt>物流</dt>
              <dd>{{.score.logisticsscore}}<!-- <i class="iconfont">&#xe819;</i> --></dd>
            </dl>
          </div>
            
              <div class="service"><a href="/message?gid={{if .shop}}{{.shop.id}}{{else}}0{{end}}"><img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/service.png">&nbsp;&nbsp;联系客服</a></div>
            
        </div>
        <div class="storeSearch">
          <form action="/shop">
            <input type="text" name="search" placeholder="搜索 产品">
            <input type="hidden" name="id" value="{{.gid}}">
            <button>搜本店</button>
          </form>
        </div>
      </div>
    </div>
    <div class="storeHd">
      <div>
        <div class="storeHdImg" style="background-image: url({{if .shop}}{{.shop.bpath}}{{else}}{{$.system.webpath}}{{end}});"></div>
        <ul>
          <!-- <li><a href="">首页</a></li> -->
          <li><a href="/shop?id={{$.gid}}">首页</a></li>
          {{range .column}}
          <li><a href="/shop?id={{$.gid}}&cid={{.id}}">{{.name}}</a></li>
          {{end}}
        </ul>
      </div>
    </div>
    <div class="prd">
      <div>
        <div class="prd_l">
          <div class="prdInfo">
            <div class="prdImgs">
              <div class="prdImg" style="background-image: url({{index .info.imgs 0}});">
                <span class="prdBigImg" style="background-image: url({{index .info.imgs 0}});"></span>
              </div>
              <ul>
                {{range $k,$v:=.info.imgs}}
                <li {{if eq $k 0}}class="ac"{{end}}><img src="{{$v}}" alt=""></li>
                {{end}}
              </ul>
            </div>
            <div class="prdCont">
              <div class="pCHd">
                <h2>{{.info.title}}</h2>
                <p>{{.info.description}}</p>
              </div>
              {{if .gbuy}}
              <div class="pCSale">
                <p><span></span>统采团购</p>
                <p style="width: 50px;float: right;line-height: 23px;color: #fff;cursor: pointer; height: 23px;">团购说明</p>
                <p style="width: 70% !important;float: left;overflow:hidden;height: 15px;color: #fff; background-color: rgba(0,0,0,0.4); border-radius: 20px; line-height: 15px; font-size: 12px; text-align: center; margin: 5px 0 !important; position: relative;">
                  <span style="text-align: center; width: 100%; height: 100%; position: absolute; top: 0; left: 0; text-shadow: 0 0 3px #333; z-index: 5;">目前 {{.gbuy.jnum}}/{{.gbuy.num}}</span>
                  <span id="jdt" style="width: 50%; height: 100%; position: absolute; top: 0; left: 0; background-color: #FFFFE0;"></span>
                </p>

                <p>距离结束<span class="hours"></span><span class="minutes"></span><span class="seconds"></span></p>
              </div>
              {{end}}
              <div class="pCPrice">
                <!-- <p class="description">开通会员享会员专享价格<a href="./vip.html">前往开通<i class="iconfont">&#xe6f1;</i></a></p> -->
                {{if .gbuy}}
                  <p class="discount" style="border-top: 1px dashed #e4393c;">团购价<span>&yen;<span style="font-size: 38px;">{{.gbuy.price}}</span></span><label>参加团购</label></p>
                  {{if .info.vprice}}
                  <p class="discount" style="color: #666 !important;text-decoration:line-through;">价格<span style="color:#666 !important">&yen;<span style="color:#666 !important">{{.info.vprice}}</span></span><label>会员专享</label></p>
                  {{else}}
                  <p class="discount" style="color: #666 !important;text-decoration:line-through;">价格<span style="color:#666 !important">&yen;<span style="color:#666 !important">{{.info.price}}</span></span></p>
                  {{end}}
                {{else}}
                  {{if .info.vprice}}
                  <p class="discount">价格<span>&yen;<span>{{.info.vprice}}</span></span><label>会员专享</label></p>
                  {{else if .info.cprice}}
                  <p class="before" style="color: #666 !important;text-decoration:line-through;">原价<s style="color:#666 !important">&yen;<span style="color:#666 !important">{{.info.price}}</span></s></p>
                  <p class="discount" style="border-top: 1px dashed #e4393c">促销价<span>&yen;<span>{{.info.cprice}}</span></span></p>
                  {{else}}
                  <p class="discount">价格<span>&yen;<span>{{.info.price}}</span></span></p>
                  {{end}}
                {{end}}
                <p class="add">发货地址<span>本产品由 {{if .shop}}{{.shop.shen}}{{.shop.shi}}{{else}}{{$.system.shen}}{{$.system.shi}}{{end}} 发出</span></p>
              </div>
              <div class="pCCoupon">
                {{range .coupon}}
                <p><span></span> {{.name}}{{if eq .isget 0}}<a class="getCoupon" data-id="{{.id}}">领取</a>{{else}}<a style="color:#999;cursor: default;">已领取</a>{{end}}</p>
                {{end}}
              </div>
              <div class="pCSaleInfo">
                <p>销量<span>{{.info.sellnum}}</span></p>
                <p>库存<span>{{.info.inventory}}</span></p>
                <p>浏览<span>{{.info.click}}</span></p>
              </div>
              <div class="pCSel">
                <dl>
                  <dt>装箱数</dt>
                  <dd>{{.info.number}}{{.info.spec}}/箱</dd>
                </dl>
                <dl>
                  <dt>外箱尺寸</dt>
                  <dd>{{.info.length}}*{{.info.width}}*{{.info.height}}</dd>
                </dl>
                {{ if .info.size }}
                <dl>
                  <dt>产品尺寸</dt>
                  <dd>{{.info.size}}</dd>
                </dl>
                {{ end }}
                {{if .info.material}}
                <dl>
                  <dt>材质</dt>
                  <dd>{{.info.material}}</dd>
                </dl>
                {{end}}
                {{if .info.weight}}
                {{if ne .info.weight "0.00"}}
                <dl>
                  <dt>重量</dt>
                  <dd>{{.info.weight}}g</dd>
                </dl>
                {{end}}
                {{end}}
                <dl class="pricem">
                  <dt>每箱</dt>
                  <dd style="color: #e4393c">&yen;{{if .info.vpricem}}{{.info.vpricem}}{{else if .info.cpricem}}{{.info.cpricem}}{{else}}{{.info.pricem}}{{end}}</dd>
                {{if .gbuy}}
                  <dt>团购每箱</dt>
                  <dd style="color: #e4393c">&yen;{{.gbuy.gprice}}</dd>
                {{end}}
                </dl>
                <dl style="display: none;" class="pricem">
                  <dt>每件</dt>
                  <dd style="color: #e4393c">&yen;{{if .info.vprice}}{{.info.vprice}}{{else}}{{.info.price}}{{end}}</dd>
                </dl>
              </div>
              <div> 
                <div class="pCAmount">
                  <dl class="gg">
                  <dt>规格 {{.info.issingle}}</dt>
                  <dd>
                    {{if .shop}}
                    <span class="spec on" data-spec="0">箱 / 每箱<em class="num">{{.info.number}}</em>{{.info.spec}}</span>
                      {{if eq .info.issingle "1"}}
                      <span class="spec" data-spec="1"><em class="num">件</em></span>
                      {{end}}
                    {{else}}
                    <span class="on">每箱<em class="num">{{.info.number}}</em>{{.info.spec}} 最少购买{{.info.minbuy}}箱</span>
                    {{end}}
                  </dd>
                </dl>
                  <dl>
                    <dt>数量</dt>
                    <dd>
                      <input name="amount" type="number" value="{{if .gbuy}}{{.gbuy.min}}{{else}}{{.info.minbuy}}{{end}}" data-min="{{if .gbuy}}{{.gbuy.min}}{{else}}{{.info.minbuy}}{{end}}">
                      <p><i class="iconfont numadd">&#xe7b6;</i><i class="iconfont numcut">&#xe7b8;</i></p>
                      <span>库存 {{.info.inventory}} 件</span>
                    </dd>
                  </dl>
                </div>
                <div class="pCBtn">
                  {{if .gbuy}}
                  <button style="background: #EEB422;color: #fff" class="buy" data-type="1">立即团购</button>
                  {{end}}
                  <button style="background-color: #e31939;color: #fff" class="buy" data-type="0">立即购买</button>
                  <button style="background-color: rgba(225,0,0,.1);color: #e31939" id="shopcarAdd">加入购物车</button>
                </div>
              </div>
            </div>
          </div>
          <style type="text/css">
            .kefu{position: relative;}
            .kefu a{position: absolute;display: block;top: 0;right: 10px;height: 40px;line-height: 40px;}
            .kefu a img{width: 18px;height: 18px;vertical-align: center}
          </style>
          <div class="prdDetail">
            <div class="prdStore">
              <div class="pSInfo">
                <p class="kefu">
                  <i class="iconfont">&#xe6d5;</i>{{if .shop}}{{.shop.name}}{{else}}{{$.system.name}}{{end}}
                  <a href="/message?gid={{if .shop}}{{.shop.id}}{{else}}0{{end}}"><img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/img/service.png">&nbsp;联系客服</a> 
                </p>
                <div class="pSInfoCont">
                  <p><i class="iconfont">&#xe7fb;</i>认证店铺</p>
                  <dl>
                    <dt>服务</dt>
                    <dd>{{.score.avgscore}}<!-- <i class="iconfont">&#xe818;</i> --></dd>
                  </dl>
                  <dl>
                    <dt>物流</dt>
                    <dd>{{.score.logisticsscore}}<!-- <i class="iconfont">&#xe819;</i> --></dd>
                  </dl>
                </div>
                <div class="pSInfoBtn">
                  <button><a href="/shop?id={{if .shop}}{{.info.gid}}{{else}}0{{end}}" style="color: #fff">进店逛逛</a></button>
                  {{if eq .info.iscollect 1}}
                  <button disabled>已收藏</button>
                  {{else}}
                  <button id="collect" data-id="{{if .shop}}{{.info.gid}}{{else}}0{{end}}">收藏店铺</button>
                  {{end}}
                </div>
              </div>
              <div class="pSPrds">
                <p>相关推荐</p>
                {{range .grecommend}}
                <a href="/product/content?id={{.id}}">
                <dl>
                  <dt><img src="{{.pathname}}"></dt>
                  <dd>
                    <p>{{.title}}</p>
                    {{if .vprice}}
                    <p><b>&yen;{{.vprice}}</b><s>&yen;{{.price}}</s></p>
                    {{else}}
                    <p><b>&yen;{{.price}}</b></p>
                    {{end}}
                  </dd>
                </dl>
                </a>
                {{end}}
              </div>
            </div>
            <div class="prdDetailCont">
              <div class="pDHd">
                <span class="on">商品详情</span>
                <span>累计评价</span>
              </div>
              <div class="pDParameter">
                <p>品牌名称：{{.info.bname}}</p>
                <p>型号：{{.info.model}}</p>
                <p>长度(cm/箱)：{{.info.length}}</p>
                <p>宽度(cm/箱)：{{.info.width}}</p>
                <p>高度(cm/箱)：{{.info.height}}</p>
                <p>重量(g/件)：{{.info.weight}}</p>
                <p>装箱数：{{.info.number}}</p>
                <p>规格：{{.info.spec}}</p>
                <p>条形码：{{.info.barcode}}</p>
                {{if .info.material}}
                <p>材质：{{.info.material}}</p>
                {{end}}
                {{range .info.attrs}}
                <p>{{.name}}：{{.value}}</p>
                {{end}}
                {{range .info.parameter}}
                <p>{{.key}}：{{.value}}</p>
                {{end}}
              </div>
              <div class="pDInfo">
                {{if .info.content}}
                {{str2html .info.content}}
                {{end}}
              </div>
              <div class="pDEva">
                {{range .evaluate}}
                <div>
                  <dl>
                    <dt>
                      <p>{{.content}}</p>
                      <p>
                        {{range .imgs}}
                        <span style="background-image:url({{.pathname}})"></span>
                        {{end}}
                      </p>
                    </dt>
                    <dd>
                      <p>数量：<span>{{.num}}</span></p>
                      <p>评分：<span><img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/img/prd/{{.score}}x.png"></span></p>
                    </dd>
                    <dd>{{.monicker}} <span>(匿名)</span></dd>
                  </dl>
                  <p>{{.addtime}}</p>
                </div>
                {{end}}
                {{if .paginator}}
                {{if ne .paginator.totalpages 1}}
                <div class="pageView">
                  <b class="btn">
                    {{if ne .paginator.currpage 1}}
                    <a class="gopage" data-page="{{.paginator.prevpage}}"><b>&lt;&lt;上一页</b></a>
                    {{else}}
                    <b>&lt;&lt;上一页</b>
                    {{end}}
                    {{range $index,$page := .paginator.pages}}
                    {{if eq $.paginator.currpage $page}} 
                    <b>{{$page}}</b>
                    {{else}}
                    <a class="gopage" data-page="{{$page}}"><b>{{$page}}</b></a>
                    {{end}}
                    {{end}}
                    <!-- <b class="more">...</b> -->
                    {{if eq .paginator.currpage .paginator.totalpages}}
                    <b>下一页&gt;&gt;</b>
                    {{else}}
                    <a class="gopage" data-page="{{.paginator.nextpage}}"><b>下一页&gt;&gt;</b></a>
                    {{end}}
                  </b>
                  <b class="other">
                    共{{.paginator.totalpages}}页，到第<input type="text" name="p">页<button id="go">确定</button>
                  </b>
                </div>
                {{end}}
                {{end}}
              </div>
            </div>
          </div>
        </div>
        <div class="prd_r">
          <div class="pSPrds">
            <p>相关推荐</p>
            {{range .recommend}}
            <a href="/product/content?id={{.id}}">
            <dl>
              <dt><img src="{{.pathname}}"></dt>
              <dd>
                <p>{{.title}}</p>
                {{if .vprice}}
                <p><b>&yen;{{.vprice}}</b><s>&yen;{{.price}}</s></p>
                {{else}}
                <p><b>&yen;{{.price}}</b></p>
                {{end}}
              </dd>
            </dl>
            </a>
            {{end}}
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript"></script>
      {{template "pc/public/foot.html" .}}
  </body>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/jquery.min.js"></script>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/admin/js/xcConfirm.js"></script>
  <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/js/toast.js"></script>
  <!-- <script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/pc/frame/sui/js/SUI.js"></script> -->
  <script type="text/javascript">
    var spec=0;
  $('.spec').click(function(){
    $('.pricem').hide()
    $('.pricem').eq($(this).index()).show()
    $('.spec').each(function(){
      $(this).attr('class','spec')
    })
    $(this).attr('class','spec on')
    spec=$(this).attr('data-spec')
  })
      var prdImg = document.querySelector(".prdImg"),
          prdImgs = document.querySelector(".prdImg span"),
          prdImgA = document.querySelector(".prdImg:after"),
          css = document.createElement("style"),
          sel = document.querySelectorAll(".pCSel dl"),
          detail = document.querySelectorAll(".pDHd span"),
          detailC = document.querySelector(".pDInfo"),
          evaC = document.querySelector(".pDEva"),
          sel = document.querySelectorAll(".pCSel dl"),
          data = {},
          hours = document.querySelector(".hours"),
          minutes = document.querySelector(".minutes"),
          seconds = document.querySelector(".seconds");
      {{if .gbuy}}
      var sysj={{.gbuy.sysj}};
      sysj=sysj.split(":");
      hours.innerHTML=sysj[0]
      minutes.innerHTML=sysj[1]
      seconds.innerHTML=sysj[2]
      var timer = setInterval(function(){
        if (seconds.innerHTML > 0) {
          seconds.innerHTML = parseInt(seconds.innerHTML) - 1
        }else if (minutes.innerHTML > 0) {
          minutes.innerHTML = parseInt(minutes.innerHTML) - 1
          seconds.innerHTML = 59
        }else if (hours.innerHTML > 0) {
          hours.innerHTML = parseInt(hours.innerHTML) - 1
          minutes.innerHTML = 59
          seconds.innerHTML = 59
        }
      },1000)
      {{end}}
    
      detail[0].onclick = function(){
        detail[0].className = "on"
        detail[1].className = ""
        evaC.style.display = 'none'
        detailC.style.display = 'block'
      }
      detail[1].onclick = function(){
        detail[1].className = "on"
        detail[0].className = ""
        detailC.style.display = 'none'
        evaC.style.display = 'block'
      }
      var X = Y = 65;
      document.body.appendChild(css)
      prdImg.onmousemove = function(e){
        X = e.offsetX < 65?65:(e.offsetX > 420-65?420-65:e.offsetX)
        Y = e.offsetY < 65?65:(e.offsetY > 420-65?420-65:e.offsetY)
        css.innerText = ".prdImg:hover:after{ top:calc("+Y+"px - 65px) !important; left:calc("+X+"px - 65px) !important; }"+
                        ".prdImg:hover .prdBigImg { background-position: "+((X - 65) / (420 - 130) * 100)+"% "+((Y - 65) / (420 - 130) * 100)+"%; }"
      }
      for (var i = 0; i < document.querySelectorAll(".prdImgs li").length; i++) {
        (function(i){
          document.querySelectorAll(".prdImgs li")[i].onmouseover = function(e){
            document.querySelector(".prdImgs .ac").className = ""
            this.className = "ac"
            prdImg.style.backgroundImage = 'url('+this.querySelector("img").src+')'
            prdImg.querySelector(".prdBigImg").style.backgroundImage = 'url('+this.querySelector("img").src+')'
          }
        })(i)
      }
  </script>
  <script type="text/javascript">
{{if .gbuy}}

        var bfb={{.gbuy.jnum}}/{{.gbuy.num}}*100
        // document.getElementById('jbt').style.width=bfb+"%"
        $('#jdt').css('width',bfb+"%")
{{end}}
    $('.numadd').click(function(){
      var num=parseInt($('input[name="amount"]').val())+1
      $('input[name="amount"]').val(num)
    })
     $('.numcut').click(function(){
      var min={{if .gbuy}}{{.gbuy.min}}{{else}}{{.info.minbuy}}{{end}}
      var num=parseInt($('input[name="amount"]').val())
      if (num>min){ 
        $('input[name="amount"]').val(num-1)
      }else{
        return
      }
    })
    $('input[name="amount"]').change(function () {
      var min = $(this).attr("data-min")
      var val = $(this).val()
      $(this).val(val < min ? min : val)
    })
    var pid={{.info.id}};

   var inventory=parseInt({{.info.inventory}});
    $('.buy').click(function(){
      var num=$('input[name="amount"]').val()
      var type=$(this).attr('data-type')
      if (num>inventory){
        wxc.xcConfirm("库存不足","info")
      }else{
        $.ajax({
          url:'/shopcar/buy',
          data:{num:num,pid:pid,type:type,spec:spec},
          success:function(res){
            if(res.status==0){
              showToast("网络繁忙,请稍后再试")
            }else if(res.status==1){
              window.location.href='/shopcar/sure?cid='+res.cid
            }else{
              wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
                window.location.href="/login"
              }})
            }
          }
        })
      }

    })
    $('#shopcarAdd').click(function(){
      var num=$('input[name="amount"]').val()
      if (num>inventory){
        wxc.xcConfirm("库存不足","info")
      }else{
        $.ajax({
          url:'/shopcar',
          type:'post',
          data:{num:num,pid:pid,spec:spec},
          success:function(res){
            if(res==0){
              showToast('网络繁忙,请重试');
            }else if(res==1){
              showToast('加入购物车成功');
            }else if(res==2||res==962){
              wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
                window.location.href="/login"
              }})
            }else if(res==3){
              showToast('库存不足');
            }
          }
        })
      }
   })
    $('.getCoupon').click(function(){
      var id=$(this).attr('data-id')
      var that=$(this)
      $.ajax({
        url:'/product/getcoupon',
        data:{yid:id},
        success:function(res){
          if(res==2){
            wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
            window.location.href="/login"
          }})
          }else if(res==1){
            showToast("领取成功~")
            that.html(已领取)
            that.css('color','#999')
            that.css('cursor','default')
            that.attr('class','')
          }else if(res==0){
            showToast("网络繁忙,请稍后再试!")
          }else if(res==3){
            that.html(已领取)
            that.css('color','#999')
            that.css('cursor','default')
            that.attr('class','')
          }
        }
      })
    })
    function flush(){
      $('.gopage').click(function(){
        var page=$(this).attr('data-page')
        pageChange(page)
      })
      var totalpages={{.paginator.totalpages}};
      $('#go').click(function(){
        var num=$('input[name="p"]').val()
        if(num<=totalpages){
          pageChange(num)
        }
      })
    }
    flush()
    function pageChange(page){
      $.ajax({
        url:window.location.href,
        data:{page:page},
        success:function(res){
          if(res){
            var eva=res.evaluate
            var html=``;
            for(var i=0;i<eva.length;i++){
              // `+eva[i].content+`
              html+=`<div><dl><dt><p>`+eva[i].content+`</p><p>`
              if(eva[i].imgs){
                for(var j=0;j<eva[i].imgs.length;j++){
                  html+=`<span style="background-image:url(`+eva[i].imgs[j].pathname+`)"></span>`
                }
              }
              html+=`</p></dt><dd><p>数量：<span>`+eva[i].num+`</span></p>
                      <p>评分：<span><img src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/img/prd/`+eva[i].score+`x.png"></span></p>
                    </dd> <dd>`+eva[i].monicker+` <span>(匿名)</span></dd> </dl> <p>`+eva[i].addtime+`</p></div>`
            }
            if(res.paginator){
              var pr=res.paginator
              if(pr.totalpages>1){
                html+=`<div class="pageView"><b class="btn">`
                if(pr.currpage!=1){
                  html+=`<a class="gopage" data-page="`+pr.prevpage+`"><b>&lt;&lt;上一页</b></a>`
                }else{
                  html+=`<b>&lt;&lt;上一页</b>`
                }
                for(var i=0;i<pr.pages.length;i++){
                  if(pr.currpage==pr.pages[i]){
                    html+=`<b>`+pr.pages[i]+`</b>`
                  }else{
                    html+=`<a class="gopage" data-page="`+pr.pages[i]+`"><b>`+pr.pages[i]+`</b></a>`
                  }
                }
                if(pr.currpage==pr.totalpages){
                  html+=`<b>下一页&gt;&gt;</b>`
                }else{
                  html+=`<a class="gopage" data-page="`+pr.nextpage+`"><b>下一页&gt;&gt;</b></a>`
                }
                html+=`</b><b class="other">共`+pr.totalpages+`页，到第<input type="text" name="p">页<button id="go">确定</button>
                  </b>
                </div>`
              }
            }
            $('.pDEva').html(html)
            flush()
          }
        }
      })
    }
    $('#collect').click(function(){
      var id=$(this).attr('data-id');
      var that=this
      $.ajax({
        url:'/shop',
        data:{id:id},
        type:'post',
        success:function(res){
          if (res==1) {
            showToast('关注成功');
            that.disabled=true
            that.innerHTML='已收藏'
          }else if(res==2){
            wxc.xcConfirm("您还没有登入,请先登入","confirm",{onOk:function(){
              window.location.href="/login"
            }})
          }else{
            showToast("网络繁忙,请稍后再试!")
          }
        }
      })
    })
  </script>
</html>